<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<%@ taglib prefix="fn" uri="/WEB-INF/tlds/fn.tld"%>
<%@ taglib prefix="fmt" uri="/WEB-INF/tlds/fmt.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品审核</title>
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/datepicker/WdatePicker.js" type="text/javascript"></script>
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="${BasePath}/res/js/common/utils.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>
<style type="text/css">
#searchbar{
	margin-bottom: 10px;
}
.navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
.l-button-search{
	width: 50px;
	margin-left: 10px;
	padding-bottom: 2px;
	display: inline;
}
.l-button-test{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
</style>
</head>
<body style="padding:6px; overflow:hidden;">
<div id="">
	<div class="navbar">
		<span>您当前的位置：商品管理 &gt; 商品列表  &gt; ${type == 1 ? "商品审核" : "设置供应商"} </span>
	</div>
	<br/>
	<table width="100%" cellpadding="0" cellspacing="0" class="l-table-edit" style="TABLE-LAYOUT: fixed" >
		<input type="hidden" id="commoNo" name="commoNo" value="${commodity.commoNo }">
	    <tr height="15">
	        <td align="right" class="l-table-edit-td">商品名称：</td>
	        <td align="left" class="l-table-edit-td">${fn:escapeXml(commodity.commoName)}</td>
	        <td align="right" class="l-table-edit-td">品牌：</td>
	        <td align="left" class="l-table-edit-td">${fn:escapeXml(commodity.brandName)}</td>
	        <td align="right" class="l-table-edit-td">商品类型：</td>
	        <td align="left" class="l-table-edit-td">
	        <c:choose>
	        		<c:when test="${commodity.commoType == 0 }">
	        			商品
	        		</c:when>
	        		<c:when test="${commodity.commoType == 1}">
	        			赠品
	        		</c:when>
	        		<c:when test="${commodity.commoType == 2}">
	        			免费商品
	        		</c:when>
	        		<c:when test="${commodity.commoType == 3}">
	        			虚拟商品
	        		</c:when>
	        		<c:otherwise>
	        			&nbsp;
	        		</c:otherwise>
	        </c:choose>		
	        </td>
	        <td align="right" class="l-table-edit-td">审核状态：</td>
	        <td align="left" class="l-table-edit-td">
	        	<c:choose>
	        		<c:when test="${commodity.checkState == 0 }">
	        			未审核
	        		</c:when>
	        		<c:when test="${commodity.checkState == 1 }">
	        			已审核
	        		</c:when>
	        		<c:when test="${commodity.checkState == 2 }">
	        			已拒绝
	        		</c:when>
	        		<c:otherwise>
	        			&nbsp;
	        		</c:otherwise>
	        	</c:choose>
	        </td>
	    </tr>
	    <tr height="15"></tr>
	    <tr>
	    	<td align="right" class="l-table-edit-td" style="vertical-align: top;">商品描述：</td>
	    	<td align="left" colspan="6" class="l-table-edit-td" style="word-break: break-all; word-wrap:break-word;">${fn:escapeXml(commodity.description)}</td>
	    </tr>
	    <c:if test="${commodity.checkReason != null}">
	     <tr height="15"></tr>
	     <tr>
	    	<td align="right" class="l-table-edit-td" style="vertical-align: top;">审核描述：</td>
	    	<td align="left" colspan="6" class="l-table-edit-td" style="word-break: break-all; word-wrap:break-word;">${fn:escapeXml(commodity.checkReason)}</td>
	    </tr>
	    </c:if>
	    <tr height="15"></tr>
	    <c:if test="${type == 1}">
	    <tr>
	    	<td align="center" colspan="8" class="l-table-edit-td">
	    		<c:forEach items="${roleVos}" var="item">
	    		<c:if test="${item.roleCode=='GOODS_SUPERVISOR' or item.roleCode == 'SYSTEM_ADMIN'}">
	    		<c:if  test="${commodity.checkState ==0}">
				<input type="button" value="审核通过" id="checkBtn1" class="l-button l-button-test"  />
				<input type="button" value="审核不通过" id="checkBtn2" class="l-button l-button-test"  />
				</c:if>
				</c:if>
				</c:forEach>
	    	</td>
	    </tr>
	    </c:if>
	</table>
	
</div>
<div id="maingrid6" style="margin:0; padding:0"></div>

<div  style="margin:0; padding:0">

</div>
  <div style="display:none;">
  <!-- g data total ttt -->
</div>

<br/>
	&nbsp;&nbsp;<input  type="button" id="tests" style="margin-left: 1550px;" value="返回" class="l-button l-button-test" >
	<br/><br/>
<script type="text/javascript">

$("#checkBtn1").click(function() {
	commoCheck(1);
});	
$("#checkBtn2").click(function() {
	commoCheck(2);
});	


var list = new Array();

function commoCheck(state) {
	var commoNo=$("#commoNo").val();
	var msg = state == 1 ? '确定审核通过吗?' : '确定审核不通过吗?';
	$.ligerDialog.confirm(msg, function (yes) { 
	  	  if(yes){
	  		$.post("getIsSetSupplier.do?commoNo=" +commoNo, function(data) {
	  			if(data != "") {
	  				$.ligerDialog.warn("货品条码"+data+" 未设置供应商,请先设置供应商!");
	  				return false;
	  			}else{
	  				if(state==2){
	  					var m =$.ligerDialog.open({title:'商品审核',url:'${BasePath}/product/commoditymgt/to_check_nopass.do?commoNo=' + commoNo+'&checkState=2&pTabid='+WIN_TAB.getSelectedTabItemID()+'',height:350,width:600,isResize: false, isDrag: false });
	  				 	
	  			       	m.show();
	  				}else{
	  					$.post("checkCommodity.do?commoNo=" + $("#commoNo").val() + "&checkState=" +state, function(data) {
		  		  			if(data.toLowerCase() == "success") {
		  		  				window.parent.f_tip('审核操作成功');
		  		  				window.location.href="${BasePath}/product/commoditymgt/toPageCommodityList.do";
		  		  				close_liger_tab();
		  		  			} else {
		  		  				window.parent.f_tip(data);
		  		  			}
		  		  		});
	  				}
	  				
	  			}
	  		});
	  	} });	
}


	var type = ${type};
	var grid6 = null;
    $(function () {
      
    	grid6 = $("#maingrid6").ligerGrid({
  	      columns: [
  	              	{ display: '商品名称', name: 'commoName',render: function(rowdata, rowindex, value){
  	              		value='${fn:escapeXml(commodity.commoName)}';
  	              		return value;
  	              	}},
  	                { display: '货品编号', name: 'prodNo'},
  	              	{ display: '货品条码', name: 'prodBarCode'},
  	                { display: '销售类型', name: 'saleType', render: function(rowdata, rowindex, value){
  	                	if(value == "1") {
  	                		return "购销";
  	                	} else if(value == "2") {
  	                		return "代销";
  	                	} else {
  	                		return "";
  	                	}
  	                }},
  	                { display: '库存类型', name: 'inventoryType', render: function(rowdata, rowindex, value){
  	                	if(value == "1") {
  	                		return "实库";
  	                	} else if(value == "2") {
  	                		return "虚库";
  	                	} else {
  	                		return "";
  	                	}
  	                }},
  	              	{ display: '含税零售价', name: 'salePrice'},
	              	{ display: '税率(%)', name: 'prodRate'},
  	                { display: '未税零售价', name: 'unSalePrice'},
  	            	{ display: '最低订货数量 ', name: 'buyNum'},
  	                { display: '箱包装规格', name: 'casePakgSize'},
  	              	{ display: '单位', name: 'prodUnit'},
  	              	{ display: '规格', name: 'optionNames'},
  	              	{ display: '供应商', isSort: false, render: function (rowdata, rowindex, value){
	                   	var  h = "";
	                   	if(type == '1'){
	                   		h+="<a href='javascript:showSppliers(\""+rowdata.prodNo+"\");'>查看</a>";
	                   	}else if(type == '2'){
	                   		h+="<a href='javascript:setSppliers("+rowindex+");'>设置</a>";	                   		
	                   	};
	                    return h;
	                }}
  	                ], 
  	                width: '100%',
  	                height: '94%',
  	                dataType: 'server', 
  	                dataAction: 'server',
  	                pagesizeParmName: 'pageSize',
  	                parms: [
  	                        {name: "commoNo", value:$("#commoNo").val()}
  	                	],
  	                url: "ajaxToProdList.do"    		
  		
  		
  		});    	  
        
    });
    
    function showSppliers(prodNo) {
    	//var prodNo=grid6.getData()[rowindex].prodNo;
    	var url = "${BasePath}/product/commoditymgt/getToListSelectSupplier.do?prodNo='"+prodNo+"'";

    	var m =$.ligerDialog.open({
				title:'查看供应商',
				url:url,
				height:500,width:700,
				buttons: [{ text: '关闭', onclick: function (item, dialog) { dialog.close(); } }],
				isResize: false, 
				isDrag: false 
		});
		m.show(); 
	};
	

	function setSppliers(rowindex) {
		var prodNo=grid6.getData()[rowindex].prodNo;
		var saleType=grid6.getData()[rowindex].saleType;
		var salePrice=grid6.getData()[rowindex].salePrice;
		var prodRate=grid6.getData()[rowindex].prodRate;
		
    	var url = "${BasePath}/product/commoditymgt/to_list_select_supplier.do?prodNo="+prodNo+"&saleType="+saleType+"&salePrice="+salePrice+"&prodRate="+prodRate+"&brandNo="+'${fn:escapeXml(commodity.brandNo)}';
    	url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
    	var m =$.ligerDialog.open({
			title:'设置供应商',
			url:url,
			height:500,width:700,
			buttons: [{ text: '确定', onclick: function (item, dialog) {
							dialog.frame.addProductToList();
							if(dialog.frame.isSuccess == "success"){
								dialog.close();
								
								
							}
					  }},
			          { text: '取消', onclick: function (item, dialog) { dialog.close(); } }],
			isResize: false, 
			isDrag: false 
		});
		m.show();
	};
	
	// 取消
	$("#tests").click(function() {
		close_liger_tab();
	});
</script>
</body>
</html>